<!--
 * @描述信息:  入口页
 * @Author:   hunk
-->
<script>
import {gettoken} from '@/apis/user'
export default {
  onLaunch: function() {
    console.log('App Launch')
    // uni.setLocale('zh-Hans')
     this.get_wx_access_token()
     setTimeout(()=>{
      //  this.notice()
     },5000)
  },
  onShow: function() {
    console.log('App Show')
  },
  onHide: function() {
    console.log('App Hide')
  },
  mpunted(){
   
  },
  methods:{
    //获取acc_token
    get_wx_access_token() {
      console.log('1313')
    //   console.log('acctoken')
    //    let appid ='wx30089e25b0b08834'
    //    let secret= '586d3c4c0cf67ecbf5990866cfcb6fc7'
    // return uni.request({
    //     method: 'get',
    //     url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appid}&secret=${secret}`,
    //     dataType: 'json',
    //     timeout: 30000
    // }).then(res => {
    //     let [err, success] = res
    //     if (success.statusCode == 200) {
    //       console.log(success.data.access_token)
    //       this.acc_token= success.data.access_token
    //         return success.data.access_token
    //     }
    // })
     gettoken().then(e=>{
        this.acc_token=e.data.accessToken
      
     })
},
 // 通知
			notice() {
				let self = this
//下方的thing1，thing2和其他，对应的是你选取模板的模板详情中的字段名称(可在小程序后台模板查看对应的字段，要和上面的字段一样)，需要更改成你自己的
				const  pushmsg = {
					"touser": this.$store.state.baseStore.userInfo.openid,
					"template_id": "48y4VNZO7YvZw_NHgWLT6WSJrR9OoECrBwHPKrzM2Uc",
          "page":"pages/index/index",
					"data": {
						"thing1": {
							"value": "预约项目"
						},
						"time2": {
							"value": "2019-12-26 16:00"
						},
						"thing3": {
							"value": "客户名称"
						},
						"phone_number4": {
							"value": "19941773278"
						},
						"thing6": {
							"value": "服务地点"
						}
					}
				}
				wx.request({
					url: 'https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=' + this.acc_token,
					data: JSON.stringify(pushmsg),
					method: 'POST',
          miniprogram_state: "formal", //developer为开发版；trial为体验版；formal为正式版；非必传
					success: function(res) {
						console.log(res)
					}
				})
			},
  }
}
</script>

<style lang='scss'>
@import './assets/style/h5.scss';
@import './assets/style/weixin.scss';
@import './assets/fonts/iconfont.scss';
.tenantHome2{
.uni-data-checklist .checklist-group .checklist-box{
  padding: 20rpx 0 25rpx 0 !important;
  margin-right: 0 !important
}
.uni-data-checklist .checklist-group .checklist-box .checklist-content .checklist-text{
  font-size: 28rpx;
  font-weight: 800;
  color:black;
}

.uni-data-checklist .checklist-group .checklist-box{
  border-bottom: 1px solid #ddd;
  border-color: #ddd !important;
  width:100%
}
.uni-data-checklist .checklist-group .checklist-box .radio__inner {
  margin-left:50rpx
}
.uni-forms-item__inner {
  padding-bottom : 0 !important;
}
.uni-forms-item__label .label-text {
  font-size: 30rpx !important;
  color:black;
  font-weight: 900;
}
.uni-data-checklist .checklist-group .checklist-box .radio__inner {
  margin-left:50rpx
}
}

.is-disabled {
    background-color: #ffffff !important;
    color: #0d0d0d !important;
}


</style>
